package cn.sczhyt.modules.szhy.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import cn.sczhyt.modules.szhy.entity.MeetingEntity;
import cn.sczhyt.modules.szhy.service.MeetingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import cn.sczhyt.modules.szhy.entity.MeetingScheduleEntity;
import cn.sczhyt.modules.szhy.service.MeetingScheduleService;
import cn.sczhyt.common.utils.PageUtils;
import cn.sczhyt.common.utils.R;



/**
 * 会议日程
 *
 * @author luojialin
 * @email 78357966@qq.com
 * @date 2021-03-24 10:40:08
 */
@Api(tags = "PC端会议日程")
@RestController
@RequestMapping("szhy/meetingschedule")
public class MeetingScheduleController {
    @Autowired
    private MeetingScheduleService meetingScheduleService;

    @Autowired
    private MeetingService meetingService;

    /**
     * 列表
     */
    @ApiOperation("所有会议列表")
    @RequestMapping("/list")
    public R list(){

        PageUtils page = meetingScheduleService.listAll();

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @ApiOperation("会议日程所有列表")
    @GetMapping("/info/{meetingId}")
    public R info(@PathVariable("meetingId") String meetingId){

		List<MeetingScheduleEntity> list = meetingScheduleService.getByMeetingId(meetingId);


        return R.ok().put("data", list);
    }

    /**
     * 保存
     */
    @ApiOperation("保存会议日程")
    @PutMapping("/save")
    public R save(@RequestBody MeetingScheduleEntity meetingSchedule){

        System.out.println(meetingSchedule);

        meetingScheduleService.save(meetingSchedule);

        return R.ok();
    }

    /**
     * 修改
     */
    @ApiOperation("修改会议日程")
    @PostMapping("/update")
    public R update(@RequestBody MeetingScheduleEntity meetingSchedule){

        meetingScheduleService.updateById(meetingSchedule);

        return R.ok();
    }

    /**
     * 删除
     */
    @ApiOperation("删除会议日程")
    @DeleteMapping("/delete")
    public R delete(@RequestBody String[] scheduleIds){
		meetingScheduleService.removeByIds(Arrays.asList(scheduleIds));

        return R.ok();
    }

}
